/*
 * @Author: your name
 * @Date: 2021-02-28 13:37:13
 * @LastEditTime: 2021-03-01 12:48:54
 * @LastEditors: Please set LastEditors
 * @Description: 菜单目录管理
 * @FilePath: \jianfa-api\routes\admin\menu.js
 */
// 菜单目录管理
const express = require('express');
const router = express.Router();
const Result = require('../../models/result');
const { getMenuService  ,getMenuTowService ,getMenuFileNoPageService} = require('../../service/menuService');

//获取三级菜单列表
router.post('/get_menu', async (req, res, next) => {
 try {
  const { status, results } = await getMenuService(req.body)
  if (status) {
   new Result(results, '获取成功').success(res)
  }
 } catch ({ err }) {
  new Result(err, '获取失败').fail(res)
 }

})
//获取二级菜单列表
router.post('/get_menu_tow', async (req, res, next) => {
 try {
  const { status, results } = await getMenuTowService(req.body)
  if (status) {
   new Result(results, '获取成功').success(res)
  }
 } catch ({ err }) {
  new Result(err, '获取失败').fail(res)
 }

})
//获取三级菜单列表数据
router.post('/get_menu_flies', async (req, res, next) => {
 try {
  const { status, results } = await getMenuFileNoPageService(req.body)

  if (status) {
   let data = { results, total: global.all_let.TOTAL }
   global.all_let.TOTAL != null ? null : delete data.total
   new Result(data, '查询成功').success(res)
  }
 } catch ({ err }) {
  new Result(err, '获取失败').fail(res)
 }

})


module.exports = router;